<template>
	<view class="mainpadding" style="padding-bottom: 150rpx;" v-if="pageShow">
		<view class="mainpadding ffffff flexleft radius" v-for="(item,index) in dataAll.lists" :key="item.goodsinfo.id">
			<image :src="item.goodsinfo.image_text" class="listleftimg3 margin_right" mode=""></image>
			<view class="flexcolumnbet" style="height: 140rpx;width: 100%;">
				<view class="main_size xiaohei lianghang">{{item.goodsinfo.name}}</view>
				<view class="flexbetween" style="width: 100%;">
					<view class="titletext xiaohuang bold">{{item.goodsinfo.price}}</view>
					<view class="xiaohui main_size">*{{item.number}}</view>
				</view>
			</view>
		</view>
		<view class="mainpadding_top ffffff radius">
			<view class="titletext hei_text bold">使用门店</view>
			<view class="flexbetween xiahuaxian margin_top" v-for="item in dataAll.statis.shopinfo" :key="item.id">
				<view class="">
					<view class="main_size xiaohei bold">{{item.name}}</view>
					<view class="xiankuan margin_top" style="width: 500rpx;">
						<text class="xiaohuang ershiba margin_right2">距您{{returnKmUnit(Number(item.distance))}}</text>
						<text class="xiaohui ershiba">{{item.address}}</text>
					</view>
				</view>
				<view class="daohang" @click="openmap(item)"></view>
			</view>
		</view>
		<view class="mainpadding_top ffffff radius">
			<view class="titletext hei_text bold">备注</view>
			<textarea class="textareaclass margin_top" placeholder="请输入留言信息给卖家" v-model="remark"></textarea>
		</view>
		<view class="gudingdb mainpadding flexbetween ffffff">
			<view class="flexleft titletext bold">
				<view class="xiaohei">合计：</view>
				<view class="xiaohuang">{{dataAll.statis.pay_price}}</view>
			</view>
			<view class="bigbtn" style="width: 35%;border-radius: 50rpx;" @click="duihuan">立即兑换</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				remark:"",
				lastdata:{},
				dataAll:{},
				pageShow:false
			}
		},
		onLoad(options) {
			let data = JSON.parse(decodeURIComponent(options.msg))
			console.log(data);
			this.lastdata = data
			this.init()
		},
		methods: {
			init(){
				httpRequest.request('/api/order/getOrderGoodsList', 'POST',this.lastdata).then(res => {
					if(res.code==1){
						this.dataAll = res.data.orderData
						this.pageShow = true
					}else{
						httpRequest.toast(res.msg)
					}
				})
			},
			duihuan(){
				uni.showLoading({
					mask:true,
					title:"请稍后"
				})
				httpRequest.request('/api/order/addOrder', 'POST',{
					remarks:this.remark,
					data:this.lastdata.data
				}).then(res => {
					uni.hideLoading()
					if(res.code==1){
						let data = {
							pay_price:res.data.pay_price,
							type:1,
							order_id:res.data.order_id
						}
						uni.redirectTo({
							url:"/pages_index/zhifu?msg="+encodeURIComponent(JSON.stringify(data))
						})
					}else{
						httpRequest.toast(res.msg)
					}
				})
				
			},
			openmap(item){
				uni.openLocation({
				     latitude: Number(item.latitude),//即将传到高德或腾讯地图的终点纬度  必须是数值，字符串无效
				     longitude:Number(item.longitude),//即将传到高德或腾讯地图的终点经度  必须是数值，字符串无效
				     name: item.address,//即将传到高德或腾讯地图的店铺名称
				     address: item.address,//即将传到高德或腾讯地图的详细地址
				     scale: 18
				})
			}
		}
	}
</script>

<style>

</style>
